package com.javabaas.server.novel_server.exception;


import com.javabaas.server.novel_server.common.ModuleCode;
import com.javabaas.server.novel_server.common.StatusCode;

public class ServiceException extends RuntimeException {

    private int code;
    private String message;
    private StatusCode statusCode;

    public ServiceException(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.message = statusCode.getMsg();
        this.statusCode = statusCode;
    }

    public ServiceException(ModuleCode moduleCode, StatusCode statusCode) {
        this.code = statusCode.getCode()+moduleCode.getCode();
        this.message = statusCode.getMsg();
        this.statusCode = statusCode;
    }

    public StatusCode getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(StatusCode statusCode) {
        this.statusCode = statusCode;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
